package com.ruoyi.scrb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scrb.domain.ScrbCl;
import com.ruoyi.scrb.service.IScrbClService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产日报产量录入Controller
 * 
 * @author 刘光轩
 * @date 2022-09-28
 */
@RestController
@RequestMapping("/scrb/cl")
public class ScrbClController extends BaseController
{
    @Autowired
    private IScrbClService scrbClService;

    /**
     * 查询生产日报产量录入列表
     */
    @PreAuthorize("@ss.hasPermi('scrb:cl:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScrbCl scrbCl)
    {
        startPage();
        List<ScrbCl> list = scrbClService.selectScrbClList(scrbCl);
        return getDataTable(list);
    }

    /**
     * 导出生产日报产量录入列表
     */
    @PreAuthorize("@ss.hasPermi('scrb:cl:export')")
    @Log(title = "生产日报产量录入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScrbCl scrbCl)
    {
        List<ScrbCl> list = scrbClService.selectScrbClList(scrbCl);
        ExcelUtil<ScrbCl> util = new ExcelUtil<ScrbCl>(ScrbCl.class);
        util.exportExcel(response, list, "生产日报产量录入数据");
    }

    /**
     * 获取生产日报产量录入详细信息
     */
    @PreAuthorize("@ss.hasPermi('scrb:cl:query')")
    @GetMapping(value = "/{cDate}")
    public AjaxResult getInfo(@PathVariable("cDate") String cDate)
    {
        return AjaxResult.success(scrbClService.selectScrbClByCDate(cDate));
    }

    /**
     * 新增生产日报产量录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:cl:add')")
    @Log(title = "生产日报产量录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScrbCl scrbCl)
    {
        return toAjax(scrbClService.insertScrbCl(scrbCl));
    }

    /**
     * 修改生产日报产量录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:cl:edit')")
    @Log(title = "生产日报产量录入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScrbCl scrbCl)
    {
        return toAjax(scrbClService.updateScrbCl(scrbCl));
    }

    /**
     * 删除生产日报产量录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:cl:remove')")
    @Log(title = "生产日报产量录入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cDates}")
    public AjaxResult remove(@PathVariable String[] cDates)
    {
        return toAjax(scrbClService.deleteScrbClByCDates(cDates));
    }
}
